home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F25028_Split.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-10-04  |  1.4 KB  |  31 lines

  1. <?xml version="1.0" encoding="utf-8"?>
  2. <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
  3.     <xsl:output method="xml" indent="yes"/>
  4.     <xsl:template name="Split">
  5.         <!--This template will recursively break apart a comma-delimited string into child elements-->
  6.         <xsl:param name="strInput" select="''"/>
  7.         <xsl:param name="strDelimiter" select="','"/>
  8.         <xsl:variable name="strNextItem" select="substring-before($strInput, $strDelimiter)"/>
  9.         <xsl:variable name="strOutput" select="substring-after($strInput, $strDelimiter)"/>
  10.         <xsl:variable name="strLen" select="string-length($strNextItem)"/>
  11.         <xsl:choose>
  12.             <xsl:when test="contains($strInput,$strDelimiter)">
  13.                 <computerlanguage>
  14.                     <xsl:value-of select="$strNextItem"/>
  15.                 </computerlanguage>
  16.                 <!-- At this point, the template will recursively call itself until the last comma is found -->
  17.                 <xsl:call-template name="Split">
  18.                     <xsl:with-param name="strInput" select="$strOutput"/>
  19.                     <xsl:with-param name="strDelimiter" select="$strDelimiter"/>
  20.                 </xsl:call-template>
  21.             </xsl:when>
  22.             <xsl:otherwise>
  23.                 <!-- The otherwise clause will be reached when a comma is not located using contains() -->
  24.                 <computerlanguage>
  25.                     <xsl:value-of select="$strInput"/>
  26.                 </computerlanguage>
  27.             </xsl:otherwise>
  28.         </xsl:choose>
  29.     </xsl:template>
  30. </xsl:stylesheet>
  31.